home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4978 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: locutus.rchland.ibm.com!usenet
  2. From: pstaite@vnet.ibm.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Compile problem
  5. Date: 1 Feb 1996 22:45:10 GMT
  6. Organization: IBM OS/2 Device Driver Development  Rochester, MN
  7. Message-ID: <4erfpm$16iq@locutus.rchland.ibm.com>
  8. References: <4eol9k$gqf@fred.uswnvg.com>
  9. Reply-To: pstaite@vnet.ibm.com
  10. NNTP-Posting-Host: warpone.rchland.ibm.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4eol9k$gqf@fred.uswnvg.com>, jweddle@uswnvg.com (Jacque Weddle) writes:
  14. >Hello,
  15. >
  16. >I'm a c person trying to compile some c++ code I got
  17. >off the net. I get the error message 
  18. >
  19. >"Log.cc", line 261: error: jump past initializer (did you forget a '{ }'?)
  20.  
  21. Although you didn't post the code I'll bet the problem line is within a 
  22. switch() statement.  Something like:
  23.  
  24.  
  25. switch( foo ) {
  26.   case x:
  27.      sometype t;
  28.      break;
  29.   case y:
  30.      // do something
  31.      break;
  32.  etc...
  33.  
  34. The complaint is that the compiler feels that in the case of foo being y
  35. the sometype instance t is in scope, but hasn't been initialized.  The 
  36. way to avoid this is to add {} around that case:
  37.  
  38. switch( foo ) {
  39.   case x:
  40.      {
  41.      sometype t;
  42.      }
  43.      break;
  44.   case y:
  45.      // do something
  46.      break;
  47.  etc...
  48.  
  49. This provides a local scope for t and keeps the compiler happy.
  50.  
  51.  
  52.  
  53. Phil Staite, team OS/2
  54. internet: pstaite@vnet.ibm.com  internal: pstaite@rchland
  55.  
  56.